<template>
	<view class="home">
		<u-navbar @leftClick="leftClick" @rightClick="rightClick" placeholder :safeAreaInsetTop="true" title="流速仪列表"
			:fixed="true" rightIcon="plus">
		</u-navbar>
		<view class="conttit">
			选择流速仪
		</view>

		<!-- 提示 -->
		<view class="" v-if="cezhanlist.length == 0">
			<u-empty mode="list">
			</u-empty>
			<view class="" style="text-align: center;font-size: 40rpx; color: #666;margin-top: 50rpx;">
				请自主添加流速仪流速公式
			</view>
		</view>


		<view class="topitem" @click="urlCezhan(item)" v-for="(item, index) in cezhanlist" :key="index"
			@longpress="cezhancliFn(item.id)">
			<view class="topname">
				{{item.name}}
			</view>
			<view class="topdik">
				<view class="xishu">
					a系数：
				</view>
				<view class="nubbb">
					{{item.aa}}
				</view>
			</view>
			<view class="topdik">
				<view class="xishu">
					b系数：
				</view>
				<view class="nubbb">
					{{item.bb}}
				</view>
			</view>
			<view class="topdik">
				<view class="xishu">
					C系数：
				</view>
				<view class="nubbb">
					{{item.cc}}
				</view>
			</view>
		</view>
		<!-- 			</uni-swipe-action-item>
		</uni-swipe-action> -->
		<!-- 切换 -->
		<u-modal showCancelButton :show="showmodal" :title="titlemodal" @confirm="confirmFn"
			@cancel="cancelFn"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				titlemodal: '是否删除',
				showmodal: false,
				cezhanlist: [],
				ty: '',
				toolName: '',
				currentMeterType: null,
				cezhanID: ''
			}
		},
		onShow() {
			this.cezhanlist = this.vuex_liusuyiList
		},
		onLoad(option) {
			this.ty = option.ty
			this.toolName = option.toolName
			this.currentMeterType = option.currentMeterType
		},
		methods: {
			// 删除
			cezhancliFn(id) {
				this.cezhanID = id
				this.showmodal = true
			},
			confirmFn() {
				this.cezhanitem()
				this.showmodal = false
				console.log('确定');
			},
			cancelFn() {
				this.showmodal = false
				console.log('取消');
			},
			// 删除ID
			cezhanitem() {
				let it = this.cezhanID
				let arr = this.vuex_liusuyiList
				let index = arr.findIndex(item => item.id == it);
				if (index !== -1) {
					arr.splice(index, 1);
				}
				this.cezhanlist = arr
				uni.$u.vuex('vuex_liusuyiList', arr)
			},
			urlCezhan(item) {
				uni.$u.vuex('vuex_liusuyiData', item)
				uni.navigateTo({
					url: '/pages/currentMeasuringCar/increaseList?&toolName=' + this.toolName +
						'&currentMeterType=' + this.currentMeterType
				});
			},
			// 返回
			leftClick() {
				uni.navigateBack({
					delta: 1
				});
			},
			// 添加
			rightClick() {
				this.inCezhan()
			},
			inCezhan() {
				let ran01 = new Date().getTime()
				uni.navigateTo({
					url: '/pages/channel/currentMeterAdd?&id=' + ran01
				});
			}
		}
	}
</script>
<style scoped lang="scss">
	.topitem {
		width: 650rpx;
		margin: 30rpx auto;
		padding: 0 20rpx 20rpx 20rpx;
		border-radius: 30rpx;
		border: #ffffff solid 3rpx;
		box-shadow: 5rpx 5rpx 20rpx 5rpx #cad0d9;
		background-color: #f7fbfd;

		.topname {
			font-size: 50rpx;
			padding: 15rpx;
			color: #000000;
			text-align: center;
			margin-bottom: 20rpx;
			border-bottom: #c6d5da solid 2rpx;
		}

		.topdik {
			font-size: 50rpx;
			padding: 0 15rpx;
			line-height: 70rpx;
			color: #000000;
			display: flex;
			align-items: center;

			.xishu {
				width: 260rpx;
				display: inline-block;
				text-align-last: justify;
			}

			.nubbb {
				color: #46b345;
			}
		}
	}

	.u-page {
		padding: 0;
	}

	.u-demo-block__title {
		padding: 10px 0 2px 15px;
	}

	.swipe-action {
		&__content {
			padding: 25rpx 0;

			&__text {
				font-size: 15px;
				color: $u-main-color;
				padding-left: 30rpx;
			}
		}
	}

	.conttit {
		width: 600rpx;
		margin: 0 auto;
		margin-top: 30rpx;
		text-align: center;
		color: #ffffff;
		padding: 20rpx 40rpx;
		font-size: 45rpx;
		border-radius: 30rpx;
		border: #ffffff solid 3rpx;
		box-shadow: 5rpx 5rpx 20rpx 5rpx #cad0d9;
		background-color: #46b345;
		letter-spacing: 30rpx;
	}
</style>
<style>
	page {
		/* background-color: #f8f8f8; */
	}
</style>